<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>判断是否是闰年</title>
</head>
<body>
    <script>
        function checkYear() {
            var year = prompt("请输入一个年份：");
           
            if (isNaN(year) || year === "" || year === null) {
                alert("请输入有效的年份！");
            } else {
                
                year = parseInt(year);
               
                yearLogic(year);
            }
        }

        function yearLogic(year) {
           
            if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
                alert("输入的年份是闰年！");
            } else {
                alert( "输入的年份为平年！");
            }
        }
    </script>

    <button onclick="checkYear()">输入年份</button>
</body>
</html>